package com.aiyige.page.publish.guarantee.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by usera on 2017/11/7.
 */

public class GuaranteeItem implements Parcelable {
    String title;
    String content;
    String id;
    boolean selected;
    boolean expanded;

    public GuaranteeItem() {
    }

    private GuaranteeItem(Builder builder) {
        setTitle(builder.title);
        setContent(builder.content);
        setId(builder.id);
        setSelected(builder.selected);
        setExpanded(builder.expanded);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public boolean isExpanded() {
        return expanded;
    }

    public void setExpanded(boolean expanded) {
        this.expanded = expanded;
    }

    public static final class Builder {
        private String title;
        private String content;
        private String id;
        private boolean selected;
        private boolean expanded;

        private Builder() {
            title = "";
            content = "";
            id = "";
            selected = false;
            expanded = false;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder content(String content) {
            this.content = content;
            return this;
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder selected(boolean selected) {
            this.selected = selected;
            return this;
        }

        public Builder expanded(boolean expanded) {
            this.expanded = expanded;
            return this;
        }

        public GuaranteeItem build() {
            return new GuaranteeItem(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeString(this.content);
        dest.writeString(this.id);
        dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
        dest.writeByte(this.expanded ? (byte) 1 : (byte) 0);
    }

    protected GuaranteeItem(Parcel in) {
        this.title = in.readString();
        this.content = in.readString();
        this.id = in.readString();
        this.selected = in.readByte() != 0;
        this.expanded = in.readByte() != 0;
    }

    public static final Creator<GuaranteeItem> CREATOR = new Creator<GuaranteeItem>() {
        @Override
        public GuaranteeItem createFromParcel(Parcel source) {
            return new GuaranteeItem(source);
        }

        @Override
        public GuaranteeItem[] newArray(int size) {
            return new GuaranteeItem[size];
        }
    };
}
